package Servlet;
import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;
import java.util.Enumeration;

@WebServlet("/ServletDemo05")
public class ServletDemo05 extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
   request.setCharacterEncoding("utf-8");
//        String username = request.getHeader("username");
//        String host = request.getHeader("Host");
//        String agent = request.getHeader("User-Agent");
//        System.out.println(host+"******"+agent+"******"+ username);
        //获取所有的请求头的名称
        Enumeration<String> headerNames = request.getHeaderNames();
    while (headerNames.hasMoreElements()){
        String s = headerNames.nextElement();
        String header = request.getHeader(s);
        System.out.println(header);
    }
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }
}
